<?php

defined('SYSPATH') or die('Access error!');

/**
 * 用户中心的供求评论类（前台成为申请）
 * ============================================================================
 * 功能描述： 
 *     管理自己申请的供求
 * ============================================================================
 * $Author: liuxudong $
 */
class Controller_User_Trade_Comments extends Controller_User_Trade_Post
{

    public function before()
    {
        parent::before();
        $this->template->assign('current_selected', URL::site('user/trade/comments'));
    }

    public function action_index()
    {
        $this->display_list();
    }

    public function action_supply()
    {
        $data = array();
        $data['post_type'] = 'supply';
        $this->display_list();
    }

    public function action_demand()
    {
        $data = array();
        $data['post_type'] = 'demand';
        $this->display_list($data);
    }

    public function display_list($data = '')
    {

        $trade_post_menu = array(
            array(
                'name' => '全部',
                'url' => URL::site('user/trade/comments'),
            ),
            array(
                'name' => '任务',
                'url' => URL::site('user/trade/comments/supply'),
            ),
            array(
                'name' => '需求',
                'url' => URL::site('user/trade/comments/demand'),
            ),
        );
        $this->template->assign('trade_post_menu', $trade_post_menu);
        $data['user_id'] = $this->user_detail['id'];
        $trade_list = Model::factory('trade_comments')->get_comments_post($data);
        $this->template->assign('trade_list', $trade_list['list']);
        $this->template->assign('page', $trade_list['page']);
        $this->template->assign('server_time', Date::get_time());
        $this->template->view('user_trade_list');
    }

}